﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeetCode
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x)
        {
            val = x;
            next = null;
        }

        public ListNode(int[] vals)
        {
            ListNode cur = null;
            for (int i = 0; i < vals.Length; i++)
            {
                if (cur == null)
                {
                    cur = new ListNode(vals[i]);
                    val = vals[i];
                }
                else
                {
                    cur.next = new ListNode(vals[i]);
                    if (next == null)
                    {
                        next = cur.next;
                    }
                    cur = cur.next;
                }
            }
        }
    }
}
